//
//  TenGrayShadowView.m
//  LovingPartyBuilding
//
//  Created by 刘应平 on 17/5/3.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "TenGrayShadowView.h"

@implementation TenGrayShadowView

/**  10  */
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor themeGrayColor];
       self.underTop = [UIView new];
        self.underTop.backgroundColor = [UIColor themeGrayColor];
        [self addSubview:self.underTop];
        self.underTop.sd_layout.leftEqualToView(self).topEqualToView(self).widthIs([UIScreen zj_screenWith]).heightIs(0.5 * [UIScreen zj_screenHScale]);
        
        [self setShadow:self.underTop];
    }
    return self;
}


- (void)setShadow:(UIView *)view{
    
    view.layer.shadowColor = [UIColor grayColor].CGColor;//shadowColor阴影颜色
    view.layer.shadowOffset = CGSizeMake(0,0.8);//shadowOffset阴影偏移，默认(0, -3),这个跟shadowRadius配合使用
    view.layer.shadowOpacity = 0.5;//阴影透明度，默认0
    view.layer.shadowRadius = 0.8;//阴影半径，默认3
}


- (void)setBottomShadow:(UIView *)view{
    
    view.layer.shadowColor = [UIColor grayColor].CGColor;//shadowColor阴影颜色
    view.layer.shadowOffset = CGSizeMake(0,-0.5);//shadowOffset阴影偏移，默认(0, -3),这个跟shadowRadius配合使用
    view.layer.shadowOpacity = 0.5;//阴影透明度，默认0
    view.layer.shadowRadius = 0.5;//阴影半径，默认3
}


- (void)setIsBottom:(BOOL)isBottom{
    _isBottom = isBottom;
    if (isBottom) {
       self.underBottom = [UIView new];
        self.underBottom.backgroundColor = [UIColor themeGrayColor];
        [self addSubview:self.underBottom];
        self.underBottom.sd_layout.leftEqualToView(self).bottomEqualToView(self).widthIs([UIScreen zj_screenWith]).heightIs(0.5 * [UIScreen zj_screenHScale]);
        
        [self setBottomShadow:self.underBottom];
    }else{
        [self.underBottom removeFromSuperview];
    }
}

- (void)setIsRemoveTop:(BOOL)isRemoveTop{
    _isRemoveTop = isRemoveTop;
    if (isRemoveTop) {
        [self.underTop removeFromSuperview];
    }
}
@end
